package com.chinatgl.latte.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.chinatgl.latte.delegates.BaseFragment;

import java.util.ArrayList;
@SuppressWarnings("all")
public class TabFragmentAdapter extends FragmentPagerAdapter {

    private final ArrayList<BaseFragment> fragments;

    public TabFragmentAdapter(FragmentManager fm, ArrayList<BaseFragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    /**
     * 获取标题显示的tab
     **/
    @Override
    public CharSequence getPageTitle(int position) {
        return fragments.get(position).getTitle();
    }

    /**
     * 获取页面的总数
     **/
    @Override
    public int getCount() {
        return fragments.size();
    }

    /**
     * 获取当前要显示的pager
     **/
    @Override
    public Fragment getItem(int position) {

        return fragments.get(position);
    }


}
